import DialogStore from ".";
import { observable, action, toJS } from "mobx";
import { Button, message } from 'antd';
import { each } from 'lodash';
import { WeaLocaleProvider } from "ecCom";
import API from '../../apis/cuspath';
const getLabel = WeaLocaleProvider.getLabel;
export default class DynamicNodePreviewDialogStore extends DialogStore {

    @observable nodeid;
    @observable pathStore;
    @observable readonly = false;
    @observable loading = true;
    @observable columns=[];
    @observable dataSource=[];
    @observable pagination;

    constructor(pathStore) {
        super();
        this.title = getLabel('528155','节点信息') ;
        this.style = { width: 720, height: 400 };
        this.pathStore = pathStore;
        this.hasScroll = true;
        this.columns = [
            {
            key: 'name',
            title: getLabel('528156','节点名称'),
            dataIndex: 'name',
            sorter: true
          }, {
            key: 'operator',
            title: getLabel('528157','操作者') ,
            dataIndex: 'operator',
          }];
        // this.pagination={
        //     total: this.dataSource.length,
        //     //showSizeChanger: true,
        //     onShowSizeChange(current, pageSize) {
        //       console.log('Current: ', current, '; PageSize: ', pageSize);
        //     },
        //     onChange(current) {
        //       console.log('Current: ', current);
        //     },
        // }
        this.pagination=false
        message.config({ top: 60 });
    }
    @action setColumns = (value) =>{
        this.columns = [
            {
            key: 'name',
            title: value.get('节点名称'),
            dataIndex: 'name',
            sorter: true
          }, {
            key: 'operator',
            title: value.get('操作者') ,
            dataIndex: 'operator',
          }];
    }
    @action setTitle = (value) =>{
        this.title =value;

    }


    @action open = (id) => {
        this.nodeid = id;
        this.readonly = this.pathStore.readonly
        this.buttons = [<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@brgxnd@close`} key="cancel" type="primary" onClick={this.hide}>{getLabel(309, '关闭')}</Button>];
        this.visible = true;
        this.loading = true;
        API.getDynamicNodePreviewList(id).then(result => {
            this.dataSource = result.nodes;
            this.loading = false;
        });
    }

    @action reloadTable = () => {
        this.tableStore.reloadCurrent();
    }

}
